<template>
  <div class="table-component">
    <h3>月卡信息</h3>
    <div class="parking-content">
      <div
        v-for="item in parkingList.data"
        :key="item.id"
        @click="getParking(item.id)"
        :class="parking === item.id ? 'parking-list' : 'parking-list2'"
      >
        {{ item.name }}
      </div>
    </div>
    <div class="table">
      <el-table
        :data="table.data"
        :loading="table.loading"
        style="width: 100%"
        :header-cell-style="{
          background: '#F1F1F1',
          'font-size': '14px',
          'font-weight': 600,
          color: '#333333',
        }"
        :cell-style="{
          'font-size': '14px',
          'font-weight': 400,
          color: '#333333',
        }"
      >
        <el-table-column label="序号" min-width="60">
          <template #default="scope">
            {{ (scope.$index + 1).toString().padStart(2, "0") }}
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="订单号" />
        <el-table-column prop="phone" label="绑定车牌号" />
        <el-table-column prop="phone" label="关联停车场" />
        <el-table-column prop="phone" label="订单状态" />
        <el-table-column prop="phone" label="支付方式" />
        <el-table-column prop="phone" label="实付金额（元)" />
        <el-table-column prop="phone" label="停车时长" />
        <el-table-column prop="phone" label="注册时间" />
        <template #empty>
          <el-empty :image="imgNone" />
        </template>
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination
        v-model:current-page="pagination.currentPage"
        v-model:page-size="pagination.pageSize"
        :page-sizes="pagination.pageSizes"
        layout="total,sizes, prev, pager, next, jumper"
        :total="table.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
const imgNone = new URL("@/assets/image/imgNone.png", import.meta.url).href;

const parking = ref(0);
const parkingList = reactive({
  data: [
    {
      id: 0,
      name: "路边停车",
    },
    {
      id: 1,
      name: "停车场停车",
    },
    {
      id: 2,
      name: "新能源充电",
    },
  ],
});

const getParking = (id) => {
  console.log(id);
  parking.value = id;
  getData();
};

const pagination = reactive({
  currentPage: 1,
  pageSize: 10,
  pageSizes: [10, 20, 30, 50],
});

const handleCurrentChange = (value) => {
  pagination.currentPage = value;
  getData();
};

const handleSizeChange = (value) => {
  pagination.pageSize = value;
  getData();
};

const table = reactive({
  data: [{}],
  total: 0,
  loading: true,
});

const getData = async () => {};
</script>

<style lang="less" scoped>
.table-component {
  .parking-content {
    display: flex;
    margin-top: 24px;
    .parking-list {
      padding: 12px 16px;
      border-bottom: 2px #007aff solid;
      font-weight: 400;
      font-size: 14px;
      color: #007aff;
    }
    .parking-list2 {
      padding: 12px 16px;
      font-weight: 400;
      font-size: 14px;
      color: #666666;
    }
  }
  .table {
    margin-top: 24px;
  }
  .pagination {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}
</style>